package Negocio;

import ClassesBasicas.Exames;
import DAO.RepositorioExame;
import Excecao.ExameExistenteException;
import Excecao.ExameInexistenteException;

public class CadastroExames {
	
	private RepositorioExame exames;

	public CadastroExames(RepositorioExame exame) {

		this.exames = exame;
	}
	public void atualizar(Exames exame) throws ExameInexistenteException {

		exames.atualizar(exame);
	}
	
	public void listar() throws ExameInexistenteException {

		exames.listar();
	}

	public void cadastrar(Exames exame) throws ExameExistenteException {

		String cpf = exame.getCodigo();
		if (!exames.existe(cpf)) {
			exames.inserir(exame);
		} else {
			throw new ExameExistenteException(exame.getCodigo());
		}
	}

	public void descadastrar(String cpf) throws ExameInexistenteException {

		exames.remover(cpf);
	}
	
	public Exames procurar(String codigo) throws ExameInexistenteException {

		return exames.procurar(codigo);
	}

}
